package com.cloud.form.api.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cloud.form.api.bean.FormFieldAuthorityBean;
import com.cloud.form.api.service.FormAuthorityService;
import com.cloud.form.common.result.Quokka;

@RestController
@RequestMapping("/form/api/authority")
public class FormAuthorityController {
	
	@Autowired
	private FormAuthorityService formAuthorityService;

	@RequestMapping("/listforms")
	public Quokka listFormFields(long procDefId){
		return new Quokka(true, formAuthorityService.listFormFields(procDefId));
	}
	
	@RequestMapping("/loadauths")
	public Quokka loadFormFieldAuth(long actDefId, long partId){
		return new Quokka(true, formAuthorityService.loadFormFieldAuth(actDefId, partId));
	}
	
	@RequestMapping("/saveauths")
	public Quokka saveFormFieldAuth(@RequestBody List<FormFieldAuthorityBean> auths, long actDefId, long partId){
		formAuthorityService.saveFormFieldAuth(auths, actDefId, partId);
		return new Quokka(true);
	}
	
}
